package com.gmako.service.impl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gmako.dao.BaseDAO;
import com.gmako.service.RegisterService;
@Service
public class RegisterServiceImpl implements RegisterService{
	@Autowired
	private BaseDAO baseDAO;


	/**
	 * 用户注册
	 * @author yezhenchi
	 * @param obj
	 */
	public void save(Object obj) {
		baseDAO.save(obj);
	}
	
	/**
	 * 查询用户名是否存在
	 * @author yezhenchi
	 * @param name
	 */
	public int findNameIs(String name){
		String hql = "Select count(id) from Userinfo where username= '"+name+"'";
		long user = (Long)baseDAO.loadObject(hql);
		if(user==0){
			return 0;
		}
		else
			return 1;
	}
	
	/**
	 * 查询id是否存在
	 * @author yezhenchi
	 * @param name
	 */
	public int findUidIs(int id){
		String hql = "Select count(id) from Userinfo where id= "+id;
		long user = (Long)baseDAO.loadObject(hql);
		if(user==0){
			return 0;
		}
		else
			return 1;
	}
	
	/**
	 * 查询邮箱是否存在
	 * @author yezhenchi
	 * @param name
	 */
	public int findEmailIs(String email){
		String hql = "Select count(id) from Userinfo where useremail= '"+email+"'";
		long emailis = (Long)baseDAO.loadObject(hql);
		if(emailis==0){
			return 0;
		}
		else
			return 1;
	}

}
